package com.mogist.hqc.module.route.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.mogist.hqc.R
import com.mogist.hqc.entitys.response.RouteDayVo
import talex.zsw.basecore.util.ColorTool

/**
 * 作用：订单列表
 * 作者：赵小白 email:vvtale@gmail.com  
 * 修改人：
 * 修改时间：
 * 修改备注：
 */
class RouteDayAdapter : BaseQuickAdapter<RouteDayVo, BaseViewHolder>(R.layout.item_reoute_day)
{
    override fun convert(helper: BaseViewHolder, item: RouteDayVo)
    { //iTvTitle
        helper.setText(R.id.iTvTitle, item.content)
        if (item.isSelect)
        {
            helper.setBackgroundRes(R.id.iTvTitle, R.drawable.bg_orange_ca)
            helper.setTextColor(R.id.iTvTitle, ColorTool.getColorById(R.color.text_orange))
        }
        else
        {
            helper.setBackgroundRes(R.id.iTvTitle, R.color.transparent)
            helper.setTextColor(R.id.iTvTitle, ColorTool.getColorById(R.color.text_black2))
        }
    }

    private var temp = -1
    fun setTemp(pos: Int)
    {
        temp = pos
    }

    fun getTemp(): Int
    {
        return temp
    }

    fun changeSelect(pos: Int)
    {
        if (temp == pos)
        {
            return
        }
        if (temp >= 0)
        {
            data[temp].isSelect = false
        }
        if (data.size > pos)
        {
            data[pos].isSelect = true
            temp = pos
        }
        notifyDataSetChanged()
    }

    fun cleanTemp()
    {
        if (temp >= 0)
        {
            data[temp].isSelect = false
        }
        temp = -1
        notifyDataSetChanged()
    }
}